<?php
// 获得账号信息状态
// header("content-type:text/html;charset=UTF-8");

include_once("conn.php");
include_once("u_getLoginInfo.php");

$select_order = "SELECT * FROM order_infos WHERE user_ID = '" . $userID . "'";
$result_order = mysqli_query($connect_DB, $select_order);
if (mysqli_num_rows($result_order) > 0) {
    echo "<button type='button' class='btn btn-outline-success' disabled>有未处理信息</button>";
    exit();
}
function delAccount($connect_DB, $userID)
{
    $update = "UPDATE user_infos SET user_status = '0' WHERE user_ID = '" . $userID . "'";
    $result_up = mysqli_query($connect_DB, $update);
    if ($result_up) {
        if (!session_id()) {
            session_start();
        }
        session_unset();
        session_destroy();
        $connect_DB->close();
    }
}


if (isset($_GET['action'])) {
    delAccount($connect_DB, $userID);
}
$select = "SELECT * FROM user_infos WHERE user_ID = '" . $userID . "'";

if ($result = mysqli_query($connect_DB, $select)) {
    $row = mysqli_fetch_object($result);
} else {
    echo "查询信息错误" . $select;
    exit;
}

if ($row->user_Status == '1') {
    echo "<button type='button' class='btn btn-outline-success' onclick='delAccount()'>注销账号</button>";
}
if ($row->user_Status == "0") {
    echo "<button type='button' class='btn btn-outline-success' disabled>等待审核</button>";
}